The present disclosure relates in general to executing computer instructions that access, read, write and/or add stored data. More specifically, the present disclosure relates to executing floating-point add/subtract instructions that perform stochastic rounding using entropy from a register.
Although integers provide an exact representation for numeric values, they suffer from two major drawbacks, namely the inability to represent fractional values and a limited dynamic range. Accordingly, as integer machines computer are capable of representing real numbers (i.e., numbers that can contain a fractional part) only by using complex codes. Over the years, a variety of codes have been used in computers, but the most commonly encountered representation is that defined by the IEEE 754 Floating-Point Standard. In computing, floating-point is a trade-off between range and precision. A number is, in general, represented in floating-point approximately to a fixed number of significant digits (i.e., the significand) and scaled using an exponent. The base for the scaling is normally two, ten or sixteen. A number that can be represented exactly is of the following form, significand×baseexponent. For example, using base-10, 1.2345=12345×10−4.
The term floating-point is derived from the fact that there is no fixed number of digits before and after the decimal point. In other words, the decimal point can float. A code representation in which the number of digits before and after the decimal point is set is known as a fixed-point representation. Because of the importance of floating point mathematics in computer workloads, many microprocessors come with dedicated hardware called a floating point unit (FPU) designed specifically for the purposes of computing floating point operations. FPUs are also called math coprocessors and numeric coprocessors.
Most floating-point numbers that a computer can represent are approximations due to a variety of factors. For example, irrational numbers, such as π or √{square root over (2)}, or non-terminating rational numbers, must be approximated. The number of digits (or bits) of precision also limits the set of rational numbers that can be represented exactly. For example, the number 123456789 cannot be exactly represented if only eight decimal digits of precision are available. Providing approximations of floating-point numbers may also be done to obtain a value that is easier to report and communicate than the original. One of the challenges in programming with floating-point values is ensuring that the approximations lead to reasonable results. If the programmer is not careful, small discrepancies in the approximations can accumulate over time to the point where the final results become meaningless.
Floating-point numbers are approximated in computers using rounding. Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler representation. For example, in base-10, replacing 23.4476 with 23.45, or the square root of 2 with 1.414. Rounding exact numbers will introduce some round-off error in the reported result. Rounding is almost unavoidable when reporting many computations, particularly when dividing two numbers in integer or fixed-point arithmetic, when computing mathematical functions such as square roots, or when using a floating point representation with a fixed number of significant digits. In a sequence of calculations performed over time, these rounding errors generally accumulate.
Accordingly, it would be beneficial to provide a simple and efficient system and methodology that mitigates rounding errors over time when performing repeated arithmetic operations such as addition or subtraction using floating-point numbers in a computer.